package com.sx.wechat.security;

import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
import org.apache.oltu.oauth2.common.validators.AbstractValidator;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by lihao on 2018/1/16.
 */
public class SimpleTokenValidator extends AbstractValidator<HttpServletRequest> {
    public SimpleTokenValidator() {
        this.requiredParams.add("response_type");
        this.requiredParams.add("client_id");
        this.requiredParams.add("client_secret");
        this.requiredParams.add("username");
        this.requiredParams.add("password");
    }
    public void validateMethod(HttpServletRequest request) throws OAuthProblemException {
        String method = request.getMethod();
        if(!"GET".equals(method) && !"POST".equals(method)) {
            throw OAuthProblemException.error("invalid_request").description("Method not correct.");
        }
    }

    public void validateContentType(HttpServletRequest request) throws OAuthProblemException {
    }
}
